// 验证规则
$('#m-vip_up').validate({
    rules: {
        vip_up: {
            required: true,
            select: true
        },
        purse: {
            required: true,
            select: true
        },
        JY_password: {
            required: true,
            password: true
        }
    },
    messages: {
        vip_up: {
            required: "不能为空"
        },
        purse: {
            required: "不能为空"
        },
        JY_password: {
            required: "不能为空"
        }
    },
    errorPlacement: function (error, element) {
        $(element).siblings('.u-ts').html(error)
    },
    errorElement: 'span',
    submitHandler: function (form) {
        form.submit();
    }
});

jQuery.validator.addMethod('password', function (value, element) {
    var password = /^[a-z0-9_-]{6,18}$/.test(value);
    return this.optional(element) || password
}, '请输入6-18位字母，数字_-');

jQuery.validator.addMethod('select', function (value, element) {
    return this.optional(element) || (value !== '0')
}, '请选择相关选项');

// 生成晋升奖励
$('#vip_up').change(function () {
    var value=$(this).val();
    switch (value){
        case '1': $('.jl_nr').val('这是VIP会员的奖励'); break;
        case '2': $('.jl_nr').val('这是一星渠道专员的奖励'); break;
        case '3': $('.jl_nr').val('这是二星渠道专员的奖励'); break;
        case '4': $('.jl_nr').val('这是三星渠道专员的奖励'); break;
        case '5': $('.jl_nr').val('这是四星渠道专员的奖励'); break;
    }
});